package com.greenbook.controller.user;

import com.greenbook.dto.NoteDOC;
import com.greenbook.dto.PageDTO;
import com.greenbook.result.Result;
import com.greenbook.service.NoteSearchService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ES笔记搜索
 * 用于处理笔记搜索相关的请求
 *
 * @author leayqeay
 * @since 1.0
 */
@RestController
@RequestMapping("/noteSearch")
@RequiredArgsConstructor
@Slf4j
@Tag(name = "笔记搜索相关接口")
public class NoteSearchController {
    private final NoteSearchService noteSearchService;
    /**
     * 分页查询推荐笔记
     * @return
     */
    // TODO 暂时获取全部笔记
    @GetMapping("/pageRecommend/{currentPage}/{pageSize}")
    @Operation(summary = "分页查询推荐笔记")
    public Result<PageDTO<NoteDOC>> pageRecommend(@PathVariable int currentPage, @PathVariable int pageSize) {
        log.info("分页查询推荐笔记, currentPage: {}, pageSize: {}", currentPage, pageSize);
        return Result.success(noteSearchService.pageRecommend(currentPage, pageSize));
    }

}
